
<template>
  <div class="wrap" style="padding: 15px">
    <el-row>
      <el-form :inline="true" :model="queryParams" class="demo-form-inline">
        <el-form-item label="手机号">
          <el-input
            clearable
            v-model="queryParams.phone"
            placeholder="手机号"
          ></el-input>
        </el-form-item>
        <el-form-item label="日期">
          <el-date-picker
            v-model="date"
            type="daterange"
            value-format="yyyy-MM-dd HH:mm:ss"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            @change="getDate"
          >
          </el-date-picker>
        </el-form-item>

        <el-form-item>
          <el-button type="primary" @click="getData">查询</el-button>
        </el-form-item>
      </el-form>
    </el-row>

    <el-table :data="tableData" style="width: 100%" stripe v-loading="loading">
      <el-table-column label="手机号" prop="phone"></el-table-column>
      <el-table-column label="姓名" prop="realName"></el-table-column>

      <el-table-column label="卡类型" prop="gymRegionName">
        <p>畅玩卡</p>
      </el-table-column>
      <el-table-column label="卡名称" prop="cardName"></el-table-column>
      <el-table-column label="售价" prop="salePrice"></el-table-column>

      <el-table-column label="使用时段" prop="dailyCardDateStr">
       
      </el-table-column>
      <el-table-column label="图片" prop="picUrl">
        <template slot-scope="scope">
          <el-image
            style="width: 100px; height: 100px"
            :src="scope.row.picUrl"
            :preview-src-list="[scope.row.picUrl]"
          >
          </el-image>
        </template>
      </el-table-column>
      <el-table-column label="开卡时间" prop="createDate"></el-table-column>

      <el-table-column label="操作" width="400">
        <template slot-scope="scope">
          <el-button type="primary" size="small" @click="addGiftCard(scope.row)"
            >查看</el-button
          >
          <el-button type="primary" size="small" @click="del(scope.row)"
            >上传图片</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <div class="block" style="text-align: right; justify-content: flex-end">
      <el-pagination
        @size-change="getData"
        @current-change="getData"
        :current-page.sync="queryParams.page"
        :page-sizes="[10, 20, 30, 40]"
        :page-size.sync="queryParams.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      ></el-pagination>
    </div>
    <AddCard ref="addCard" />
    <Upload ref="upd" />
  </div>
</template>
<script>
import { playCardDel, memberDailyCardPageList, memberDailyCardShow } from '@/config/api'
import { times, divide } from "@/utils/tools"
import Upload from './upload.vue'
import AddCard from "./addCard.vue"
export default {
  components: {
    AddCard,
    Upload
  },
  data () {
    return {
      queryParams: {
        phone: undefined,
        page: 1,
        pageSize: 10,
      },
      tableData: [],
      levelList: [],
      total: 0,
      loading: false,
      balance: {},
      dialogFormVisible: false,
      date:[]
    };
  },

  created () {

    this.getData()
  },
  methods: {
    // 新增卡
    addGiftCard (record) {
      memberDailyCardShow({ id: record.id }).then(res => {
        this.$refs.addCard.addShow(res.data.result)

      })
    },
    del (record) {
      this.$refs.upd.addShow(record)

    },
    getDate (e) {
      if (e) {
        this.queryParams.startTimeStr = e[0]
        this.queryParams.endTimeStr = e[1]
      } else {
        this.queryParams.startTimeStr = ""
        this.queryParams.endTimeStr = ""
      }

    },
    getData () {
      memberDailyCardPageList(this.queryParams).then(res => {
        res.data.result.list.map(item => {
          item.salePrice = divide(item.salePrice, 100)
        })
        this.tableData = res.data.result.list
        this.total = res.data.result.total
      })
    },



  },
};
</script>
<style lang="scss" scoped>
.block {
  display: flex;
  margin: 15px 0;
  p {
    font-size: 18px;
    font-weight: bold;
    margin-right: 50px;
  }
}
</style>